Empresas
Empregos
  • Sobre nós
  • Soluções
    • Publicação de vagas
      Publique sua vaga e receba candidatos qualificados em 48h.
    • Avaliações de candidatos
      Mais de 500 testes técnicos e psicológicos, mais anti-fraude.
    • Headhunting
      Busca executiva personalizada do início ao fim.
    • Folha de Pagamento + EOR
      Dispersão de folha e EOR em mais de 15 países da LATAM.
  • Preços
  • Empregos

0

277
Visualizações
In Angular, why is the selector in component decorator called the "css selector"?

I come from a HTML CSS Javascript background and I just started learning Angular with their official tutorial "Tour of Heroes".

I noticed that the official tutorial and other Youtubers whose videos I have been watching, refer to the selector of the component as CSS Selector. I do not understand why CSS is being included in the term here.

As far as I have understood, selector of a component looks for a matching tag on the root/parent component and it is a html tag in a html page.

Unable to understand how CSS comes into the picture for the term to be a CSS Selector

@Component({
  selector: 'app-heroes', //This is what I am referring to.
  templateUrl: './heroes.component.html',
  styleUrls: ['./heroes.component.scss', './test.scss']
})
over 4 years ago · Santiago Trujillo
1 Respostas
Responde à pergunta

0

A selector in CSS defines a rule on how to match against the DOM, determining where / when a given style rule applies. In Angular, directive / component selectors use these very selectors, too, to define what elements they apply to. Element selectors (like "app-my-component") for components are what you'll see most of the time, but you're not limited to those.

For example, you could write a component with a selector of "a[href]" which matches any a element that also has an href attribute. In fact, you could even use a selector of "[href]", matching on any element with such an attribute. You could even use a selector like ":not([href])" to apply your directive on any element which does not have such an attribute.

In practice this can be quite useful, especially for directives. In fact, if you look at the source code of Angular's RouterLink directive, you'll find that it is actually implemented as two separate directives, one with a selector of a[routerLink] and one with a selector of :not(a)[routerLink].

over 4 years ago · Santiago Trujillo Relatório
Responde à pergunta
Encontrar trabalhos remotos

Descubra a nova forma de encontrar um emprego!

melhores empregos
Principais categorias de trabalho
Empresas
Postar vaga Preços Comercial
Jurídico
Termos e Condições Política de privacidade
© 2026 PeakU Inc. All Rights Reserved.
Andres GPT
Recomende algumas ofertas para mim
Preciso de ajuda